package com.asa.imgs;

import java.awt.Graphics;
import java.io.DataInputStream;
import java.io.IOException;

import com.asa.imgs.jwt.Draw;
import com.asa.imgs.jwt.GraphicsDemo;

public class BITMAPINFO {

	BITMAPINFOHEADER bmiHeader; // 位图信息头

	RGBQUAD[] bmiColors; // 颜色表 这个长度是1？？？

	int image_width;
	int image_heigh;

	int[][] imageB;
	int[][] imageG;
	int[][] imageR;
	
	
	
	public BITMAPINFO(int image_width, int image_heigh,DataInputStream dis) throws IOException {
		this.image_width = image_width;
		this.image_heigh = image_heigh;
		
		
		showRGB24(dis);
	}

	private int[][][] showRGB24(DataInputStream dis) throws IOException {
//		   this.setTitle(path);  
		// 弹出一个图片的窗口一个大小
//		  this.setSize(image_width, image_heigh);  

//		 g=this.getGraphics();  

		int skip_width = 0;
		if (!(image_width * 3 % 4 == 0)) {// 图片的宽度不为0
			skip_width = 4 - image_width * 3 % 4;
		} // 判断是否后面有补0 的情况
			// 装载RGB颜色的数据数组
		imageR = new int[image_heigh][image_width];
		imageG = new int[image_heigh][image_width];
		imageB = new int[image_heigh][image_width];

		// 按行读取 如果H,W为正则倒着来
		for (int h = image_heigh - 1; h >= 0; h--) {
			for (int w = 0; w < image_width; w++) {
				// 读入三原色
				int blue = dis.read();
				int green = dis.read();
				int red = dis.read();
				imageB[h][w] = blue;
				imageG[h][w] = green;
				imageR[h][w] = red;
				if (w == 0) {// 跳过补0项
//					System.out.println(dis.skipBytes(skip_width));
					dis.skipBytes(skip_width);
				}
			}
		}
		
		int[][][] result = new int[3][][];
		result[0] = imageR;
		result[1] = imageG;
		result[2] = imageB;

		return result;
		
	}

	public int getImage_width() {
		return image_width;
	}

	public void setImage_width(int image_width) {
		this.image_width = image_width;
	}

	public int getImage_heigh() {
		return image_heigh;
	}

	public void setImage_heigh(int image_heigh) {
		this.image_heigh = image_heigh;
	}

	public int[][] getImageB() {
		return imageB;
	}

	public void setImageB(int[][] imageB) {
		this.imageB = imageB;
	}

	public int[][] getImageG() {
		return imageG;
	}

	public void setImageG(int[][] imageG) {
		this.imageG = imageG;
	}

	public int[][] getImageR() {
		return imageR;
	}

	public void setImageR(int[][] imageR) {
		this.imageR = imageR;
	}


	
	
	
	
	
	
	
	
	
	
	
	

}
